package com.cw.DesignModel23.Ceational.PrototypePattern.cloneFramework;

import java.util.HashMap;

public class Manager {
    /**
     * 存储实例名及实例
     */
    private HashMap showcase = new HashMap();

    /**
     * 注册示例
     * @param name
     * @param proto
     */
    public void register(String name, Product proto) {
        showcase.put(name, proto);
    }

    /**
     * 根据实例名称使用实例
     * @param protoname
     * @return
     */
    public Product create(String protoname) {
        Product p = (Product) showcase.get(protoname);
        return p.createClone();
    }
}